import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;

public class FileReaderDemo {
    public static void main(String[] args) throws Exception {
        Reader fr = new FileReader("file-io\\src\\data4.txt");

        //读一个字符,读完返回-1;
//        int code = fr.read();
//        System.out.println((char) code);

        //循环读取
//        int code;
//        while((code = fr.read())!=-1){
//            System.out.print((char) code);
//        }

        //类比于字节流,字符也可以按照数组读取
        char[] buffer = new char[10];//1k字符
        int len;
        while((len = fr.read(buffer))!=-1){
            System.out.println(new String(buffer,0,len));
        }
    }
}
